<?php
require_once("../include.php");
session_start();

?>
<?php
outer();
function outer() {
echo "<head>";
echo "<script type='text/javascript' src='wz_jsgraphics.js'></script>";
echo "</head>";
echo "<script>\n";
echo "var jg_doc = new jsGraphics('canvas')\n";
echo "jg_doc.setFont('arial', '11px', Font.BOLD)\n"; 

echo "<body>";
echo "<div id = 'canvas'></div>";
echo "</body>";


function drawbom($prod,$level,$downparent) {
 global $down;
 $sql = "select subproduct from productbuilds where itemid = '$prod'";
 $list = sqlreadkeyarray($sql);
 echo ("jg_doc.setColor('#0000FF')\n");
 echo ("jg_doc.fillRect($level*100+15,$down,70,19)\n");
 if ($downparent != 0) {
  echo ("jg_doc.drawLine(($level-1)*100+85,$downparent+7,$level*100+15,$down+7)\n");
 }
 echo ("jg_doc.setColor('#FFFFFF')\n");
 echo ("jg_doc.drawStringRect('$prod',$level*100,$down+2,100,'center')\n");

 $downparent = $down;
 if ($list) {
   foreach ($list as $productid=>$item) {
    drawbom($productid,$level+1,$downparent);
    $down = $down + 20;
   }
   $down = $down - 20;
 }
}
$prod = '711'; 
$down = 20 ;
drawbom($prod,1,0);

echo "jg_doc.paint()\n";
echo "</script>";
}
?>



</html>
